﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using WarOfDev.EF;
using System.Web.Mvc;

namespace WarOfDev.Web.ViewModels
{

    public class TaskViewModel : BaseViewModel
    {
        private WarDevEntities db;
        public TaskViewModel()
        {
            db = new WarDevEntities();

            
        }

        public TaskViewModel(Task task):this()
        {
            this.ExperienceValue = task.ExperienceValue;
            this.CreatedBy = task.CreatedBy;
            this.CreatedOn = task.CreatedOn;
            this.Description = task.Description;
            this.Status = task.Status;
            this.Id = task.Id;
            this.ModifiedBy = task.ModifiedBy;
            this.ModifiedOn = task.ModifiedOn;
            this.Title = task.Title;


            if (task.Assignment != null && task.Assignment.Count > 0)
            {
                var assignemtns=task.Assignment.ToList();
                this.DeveloperId = assignemtns[0].DevId;
                this.DeveloperName = assignemtns[0].Developer.NickName;
            }
        }

        public string Description { get; set; }
        public int ExperienceValue { get; set; }
        public string Title { get; set; }
        public string AssignmentID { get; set; }
        
        [Display(Name = "Owner")]
        public string DeveloperId { get; set; }
        public string DeveloperName { get; set; }

        public int Status { get; set; }
        
        [Display(Name="Status")]
        public string StatusName { get; set; }

        public IList<SelectListItem> TaskStatusList { get; set; }
        public IEnumerable<SelectListItem> AllDeveloperList { get; set; }
    }
}
